<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .header {
            height: 30px;
            background-color: skyblue;
        }

        .header ul li {
            float: left;
            width: 40px;
            height: 30px;
            text-align: center;
            line-height: 30px;
            cursor: pointer;
            list-style: none;
        }

        .dd {
            display: none;
            background-color: tan;
        }

        #login {
            display: block;
            font-style: normal;
            width: 40px;
            height: 30px;
        }

        .body {
            height: 400px;
            background-color: #ccc;
        }
    </style>
</head>

<body>
    <div class="header">
        <ul>
            <li>
                <em id="login">登入</em>
                <div class="dd">
                    <p>私信</p>
                    <p>评论</p>
                </div>
            </li>
            <li>微博</li>
            <li>邮箱</li>
        </ul>
    </div>
    <div class="body">

    </div>
    <script>
        var login = document.getElementById('login');
        var dd = document.querySelector('.dd');
        login.onmouseover = function() {
            dd.style.display = 'block';
            login.style.backgroundColor = '#ccc';
        }
        login.onmouseout = function() {
            dd.style.display = 'none';
            login.style.backgroundColor = 'skyblue'
        }
    </script>
</body>

</html>